package com.hongkuncheng.cms.model;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;
import java.io.Serializable;

@Entity
public class ArticlePush implements Serializable {
    protected int id;
    protected String title;
    protected String source;
    protected String author;
    protected String digest;
    protected String exturl;
    protected String contents;
    protected String image;
    protected String pusher;
    protected Date pushtime;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "title", nullable = false, length = 255)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @Basic
    @Column(name = "source", nullable = false, length = 255)
    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    @Basic
    @Column(name = "author", nullable = false, length = 255)
    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    @Basic
    @Column(name = "digest", nullable = true, length = 255)
    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest == null || digest.isEmpty() ? null : digest;
    }

    @Basic
    @Column(name = "exturl", nullable = true, length = 255)
    public String getExturl() {
        return exturl;
    }

    public void setExturl(String exturl) {
        this.exturl = exturl == null || exturl.isEmpty() ? null : exturl;
    }

    @Basic
    @Column(name = "contents", nullable = true, length = -1)
    public String getContents() {
        return contents;
    }

    public void setContents(String contents) {
        this.contents = contents == null || contents.isEmpty() ? null : contents;
    }

    @Basic
    @Column(name = "image", nullable = true, length = 255)
    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image == null || image.isEmpty() ? null : image;
    }

    @Basic
    @Column(name = "pusher", nullable = false, length = 255)
    public String getPusher() {
        return pusher;
    }

    public void setPusher(String pusher) {
        this.pusher = pusher;
    }

    @Basic
    @Column(name = "pushtime", nullable = false)
    public Date getPushtime() {
        return pushtime;
    }

    public void setPushtime(Date pushtime) {
        this.pushtime = pushtime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ArticlePush that = (ArticlePush) o;
        return id == that.id &&
                Objects.equals(title, that.title) &&
                Objects.equals(source, that.source) &&
                Objects.equals(author, that.author) &&
                Objects.equals(digest, that.digest) &&
                Objects.equals(exturl, that.exturl) &&
                Objects.equals(contents, that.contents) &&
                Objects.equals(image, that.image) &&
                Objects.equals(pusher, that.pusher) &&
                Objects.equals(pushtime, that.pushtime);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, title, source, author, digest, exturl, contents, image, pusher, pushtime);
    }
}
